package com.tensai.study.java.opensource.hutool;

import cn.hutool.core.util.HexUtil;
import org.junit.Test;

/**
 * 十六进制工具测试
 *
 * @author Tensai
 */
public class HexUtilTest {

	/**
	 * 十六进制字符串转byte数组测试
	 */
	@Test
	public void decodeHexTest() {
		String code = "01030003000174FA";
		byte[] command = HexUtil.decodeHex(code);
		System.out.println();
	}

	/**
	 * 数字字符串转十六进制 前置补零
	 */
	@Test
	public void toHexTest() {
		String slaveId = "15";
		short s = Short.parseShort(slaveId);
		String code = HexUtil.toHex(s);
		if (code.length() == 1) {
			code = "0" + code;
		}
		System.out.println(code);
	}
}
